home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1986 January & February / rerun-1986-01-02.d64 / stack 64 (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  4KB  |  126 lines

  1. 100 rem*****stack*****
  2. 110 gosub2000
  3. 120 dimg(10,4)
  4. 130 forb=1to5:forl=1to3:g(b,l)=0:nextl:nextb
  5. 140 print"how many bars do you want to move
  6. 150 [153]"(2,3,4 or 5)?
  7. 160 input x
  8. 170 d=0
  9. 180 forz=1to5:ifz=xthen300:nextz
  10. 300 poke53281,5:print"[147]
  11. 310 [153]" wait
  12. 320 print" 3 [146]
  13. 330 [153]"  5  wait
  14. 340 print"   7   [146]
  15. 350 [153]"    9    wait
  16. 360 print"     11    [146]
  17. 370 [153]"123stop
  18. 400 n=5:b=11
  19. 410 forc=xto1step-1
  20. 420 g(n,1)=b:b=b-2:n=n-1:nextc:gosub1230
  21. 430 ifx=2thenmm$="9 & 11"
  22. 440 ifx=3thenmm$="7,9 & 11"
  23. 450 ifx=4thenmm$="5,7,9 & 11"
  24. 460 ifx=5thenmm$="3,5,7,9 & 11"
  25. 470 print"[144]you will be moving bars ";mm$
  26. 480 print"":input"which bar do you want to move";b
  27. 490 ifb=3andx=<4then530
  28. 500 ifb=5andx=<3then530
  29. 510 ifb=7andx=<2then530
  30. 520 if(b-3)*(b-5)*(b-7)*(b-9)*(b-11)=0then540
  31. 530 print"you may only use ";mm$;"":print spc(10)"enter again!":goto480
  32. 540 fory=1to5:forr=1to3:ifg(y,r)=bthen560
  33. 550 nextr:nexty
  34. 560 forz=yto1step-1
  35. 570 ifg(z,r)=0then590
  36. 580 ifg(z,r)<bthen600
  37. 590 nextz:goto700
  38. 600 print"that bar is under another one. makeanother choice.":print"
  39. 610 [137]480
  40. 700 [133]"place bar on which stack";l
  41. 710 [139](l[171]1)[172](l[171]2)[172](l[171]3)[178]0[167]800
  42. 720 [153]"you must choose '1', '2' or '3'":[137]700
  43. 800 [129]y[178]1[164]5:[139]g(y,l)[179][177]0[167]830
  44. 810 [130]y
  45. 820 [137]860
  46. 830 [139]b[179]g(y,l)[167]860
  47. 840 [153]"you can't place a longer bar on top of asmaller one...try again!
  48. 850 print"":goto480
  49. 860 forw=1to5:forc=1to3:ifg(w,c)=bthen910
  50. 900 nextc:nextw
  51. 910 forv=1to5:ifg(v,l)<>0then940
  52. 920 nextv
  53. 930 v=5:goto950
  54. 940 v=v-1
  55. 950 g(v,l)=g(w,c):g(w,c)=0:gosub1230
  56. 960 d=d+1
  57. 970 fory=1to5:forr=1to2:ifg(y,r)<>0then480
  58. 980 nextr:nexty
  59. 990 ifd<>2^x-1then1500
  60. 1000 gosub3190
  61. 1200 poke53281,13:print"[147][144]try again[160]('y' or 'n')";:input a$
  62. 1210 if a$="n" then 1330
  63. 1220 ifa$="y" then 130
  64. 1230 forj=1to5:p=7:fors=1to3
  65. 1240 ifg(j,s)=0then1300
  66. 1250 printtab(p-int(g(j,s)/2));
  67. 1260 forw=1tog(j,s)
  68. 1270 print"[159] [146]";
  69. 1280 nextw
  70. 1290 goto1310
  71. 1300 printtab(p);" [146]";
  72. 1310 p=p+11
  73. 1320 nexts:print:nextj:return
  74. 1330 poke53280,4:poke53281,7:print"[147]
  75. 1340 [153]"thank you...please play again soon.":[129]t[178]1[164]3000:[130]:[153]"load
  76. 1350 end
  77. 1500 poke53280,0:poke53281,8:print"[147]
  78. 1510 [139]x[178]2[167]m$[178]"3 moves"
  79. 1520 [139]x[178]3[167]m$[178]"7 moves"
  80. 1530 [139]x[178]4[167]m$[178]"15 moves"
  81. 1540 [139]x[178]5[167]m$[178]"31 moves"
  82. 1550 [153]"it took you";d;"moves.
  83. 1560 print"it could have been done in only ";m$;"
  84. 1570 [153]"try harder next time!":[129]t[178]1[164]5000:[130]:[137]1200
  85. 2000 [151]53280,8:[151]53281,3:[153]"load
  86. 2010 print"                         
  87. 2020 [153]"                         
  88. 2030 print"                         
  89. 2040 [153]"       
  90. 2050 print"               
  91. 2060 [153]"        
  92. 2070 print"                       
  93. 2080 [153]"                        
  94. 2090 print"                        ":print"":fort=1to1500:next
  95. 3000 print"[144]123
  96. 3010 [153]"   wait
  97. 3020 print"   [146]
  98. 3030 [153]"   wait
  99. 3040 print"[158] [144]3[158]   [146]
  100. 3050 [153]"stop  stop5stop    wait
  101. 3060 print"   [144]7     [146]
  102. 3070 [153]"    stop9      wait
  103. 3080 print"     [144]11      [146]":fort=1to3000:next
  104. 3090 poke53280,7:poke53281,15:print"[147]
  105. 3100 [153]"to play this game you must transfer the":[153]
  106. 3110 [153]"bars from the leftwait stack to the rightwait":[153]
  107. 3120 [153]"stack, one bar at a time, never putting":[153]
  108. 3130 [153]"a longer bar on a smaller one.":[153]"
  109. 3140 print"press <return>[146] to continue
  110. 3150 [153]"list":[133] c
  111. 3160 [151]53280,2:[151]53281,7:[153]"loadstop
  112. 3170 print"you may choose from 2 to 5 bars":print
  113. 3180 print"when you start the game.":fort=1 to 1500:next:return
  114. 3190 poke53280,7:poke53281,14:print"[147]
  115. 3200 [153]"xxxxxxxxxxxxxxxxxxxxxx
  116. 3210 print"xxxxxxxxx
  117. 3220 [153]"xxxxxxxx
  118. 3230 print"xxxxxxxx
  119. 3240 [153]"xxxxxxxxxxxxxxxxxxxxx
  120. 3250 print"xxxxxxx
  121. 3260 [153]"xxxxxxx
  122. 3270 print"xxxxxxxx
  123. 3280 [153]"xxxxxxxxxxxxxxxxx
  124. 3290 print"you did it in the least possible
  125. 3300 [153]"number of moves!!!!!":[129]t[178]1[164]2500:[130]:[142]
  126.